package com.huanf;

import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.huanf.controller.BaseController;
import com.huanf.domain.ApiKey;
import com.huanf.service.ApiKeyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;

@SpringBootApplication
@EnableScheduling//开启定时任务
public class Application {

    @Autowired
    private BaseController baseController;

    @Autowired
    private ApiKeyService apiKeyService;

    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }


    // @Scheduled(cron="0 0 12 * * ?") //每天中午12点给你发邮件报告api-key的使用情况，需要的话解开注释就能用
    // public void mailTask(){
    //     if (baseController.sendMailCode().equals(false)) {
    //         throw new SystemException(SystemEnum.MAIL_PORT_FAIL);
    //     }
    // }

    @Scheduled(cron = "0 0 8,12,18,23 * * ?")
    public void tempRecoveryQuota(){
        UpdateWrapper<ApiKey> updateWrapper = new UpdateWrapper<>();
        updateWrapper.set("status", 2);
    }
}
